package com.dating.core.ext;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

public class Lists {

	/**
	 * 创建新list集合
	 * @return
	 */
	public static <E> ArrayList<E> newArrayList() {
		return new ArrayList<E>();
	}

	/**
	 * 移除list中的重复元素
	 * @param list
	 * @return
	 */
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public static void removeDuplicateWithOrder(List<?> list){
		Set set = new HashSet<>();    
	    List newList = new ArrayList();    
	    for (Iterator iter = list.iterator(); iter.hasNext();) {    
	         Object element = iter.next();   
	         if (set.add(element)){
	        	 newList.add(element);
	         }  
	    }     
	    list.clear();    
	    list.addAll(newList);
	}
	
}
